package cn.com.oceansoft.business.mobile.danger.controller;

import cn.com.oceansoft.business.base.entity.Result;
import cn.com.oceansoft.business.mobile.danger.util.SignUtil;
import cn.com.oceansoft.business.mobile.danger.util.WeixinUtil;
import cn.com.oceansoft.nos.cache.redis.CacheBaseService;
import com.alibaba.fastjson.JSONObject;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpServletRequest;


@Controller
@RequestMapping("api/wechart")
public class WeChartController {


	/**
	 * 获取签名
	 * @param url
	 * @param request
     * @return
     */
	@ResponseBody
	@RequestMapping(value="location")
	public Result shijianc(@RequestParam("url") String url, HttpServletRequest request){
		String jsapiTicket = "";
		String cachekey = "CMCX_JSAPITICKET";
		String access_token =WeixinUtil.getAccessToken();
		jsapiTicket = WeixinUtil.getJsapiTicket(access_token);
		System.out.println("==========url：========"+url);
		System.out.println("==========jsapiTicket："+jsapiTicket);
		JSONObject json = SignUtil.getSignature(jsapiTicket, url);
		System.out.println("==========json："+json.toJSONString());
		Result result=new Result();
		result.setData(json);
		return result;
	}




}
